package com.palfund.butterknifedemo;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;


/**
 * A simple {@link Fragment} subclass.
 */
public class BlankFragment extends Fragment {
    @BindView(R.id.tv)
    TextView mTv;
    Unbinder unbinder;

    public BlankFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
            savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_blank, container, false);
        // 绑定Fragment
        unbinder = ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mTv.setText("Bind Fragment");
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        // 解除绑定
        unbinder.unbind();
    }

    @OnClick(R.id.tv)
    public void onViewClicked() {
        Toast.makeText(getContext(), "Click", Toast.LENGTH_SHORT).show();
    }
}
